package com.wenan.ui.controls.listBoxes
{
	import flash.events.MouseEvent;
	
	import mx.containers.HBox;
	import mx.controls.CheckBox;
	import mx.controls.List;
	import mx.controls.listClasses.ListBase;
	
	public class CheckboxListItemRenderer extends CheckBox
	{
		public function CheckboxListItemRenderer()
		{
			super();
			this.addEventListener(MouseEvent.CLICK,click_handler);
		}
		
		override public function set data(value:Object):void
		{
			super.data = value;
			invalidateProperties();
		}
		
		override protected function commitProperties():void
		{
			super.commitProperties();
			if (owner is ListBase)
				selected = ListBase(owner).isItemSelected(data);
		}
		
		private function click_handler(event:MouseEvent):void
		{
			dispatchEvent(new CheckListBoxItemEvent(CheckListBoxItemEvent.ITEM_SELECTED,data));
		}
	
	}
}